<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="availableLanguages" content="en-US">
    <meta name="defaultLanguage" content="en-US">
    <title>Brave</title>
    <script>
      require('babel-polyfill')
      require('vibrant/dist/Vibrant.min.js')
      const bravePort = process.env.BRAVE_PORT || 8080
    </script>
    <script src="./ext/l20n.min.js" defer></script>
    <link rel="localization" href="locales/{locale}/app.l20n">
  </head>
  <body>
    <div id="windowContainer">
      <div id="setupError" style="display: none">
        <p>
          <span>Please make sure the webpack devserver is running via:</span><br>
          <code>npm run watch</code>
        </p>

        <p>
          <span>Please consult the repository's README for more information:</span><br>
          <a href="https://github.com/brave/browser-electron/blob/master/README.md">https://github.com/brave/browser-electron/blob/master/README.md</a>
        </p>
      </div>
    </div>
  </body>
  <script>
    const createScript = function (scriptPath) {
      return new Promise(function (resolve, reject) {
        var script = document.createElement('script')
        script.type = 'text/javascript'
        script.src = scriptPath.replace(/\{port\}/, bravePort)
        script.async = true
        script.onload = resolve
        script.onerror = reject
        document.body.appendChild(script)
      });
    };
    createScript('http://localhost:{port}/webpack-dev-server.js').catch(function () {
      document.querySelector('#setupError').style.display = 'block'
    })
    createScript('http://localhost:{port}/built/bundle.js')
  </script>
</html>
